package com.aat.dxfy.mouse;

import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.InputEvent;

public class MouseController implements Runnable {
	private Robot robot;
	private volatile boolean stop = false;

	/** Creates a new instance of Main */
	public MouseController() {
		try {
			robot = new Robot();
		} catch (AWTException ex) {
			ex.printStackTrace();
		}
	}
	
	public void leftClick(int x,int y){
		robot.mouseMove(x, y);
		robot.mousePress(InputEvent.BUTTON1_MASK);
		try {
			Thread.sleep(3000);
		} catch (InterruptedException ex) {
			ex.printStackTrace();
		}
	}

	public void run() {
		while (!stop) {
			int x = 85;
			int y = 885;
			leftClick(x, y);
		}
	}

	public synchronized void stop() {
		stop = true;
	}

	/** * @param args the command line arguments */
	public static void main(String[] args) {
		MouseController mc = new MouseController();
		Thread mcThread = new Thread(mc);
		System.out.println("Mouse Controller start");
		mcThread.start();
		try {
			Thread.sleep(10000);
		} catch (InterruptedException ex) {
			ex.printStackTrace();
		}
		mc.stop();
		System.out.println("Mouse Controller stoped");
	}
}